#define DEBUG
#include <cstdio>
#define MODS 1000000007
#define MAXN 100000
#define MAXR 1000000000

using namespace std;

int min(int a, int b) {
  return a<b ? a : b;
}

int max(int a, int b) {
  return a>b ? a : b;
}

class AriPro {
public:
  long long a, d;

  AriPro() {
    a=d=0;
  }

  AriPro(long long a, long long d) {
    this->a = a%MODS, this->d = d%MODS;
  }

  AriPro operator+(AriPro x) {
    return AriPro(a+x.a, d+x.d);
  }

  long long kth(int k) {
    return (a+k*d)%MODS;
  }

  long long sum(int x, int y) {
    return (a+x*d+a+y*d)*(y-x+1)/2%MODS;
  }
};

class SegmentTree {
public:
  AriPro val;
  int sum;
  int l, r;
  SegmentTree *left, *right;

  SegmentTree(int al, int ar) {
    l=al, r=ar;
    val=AriPro();
    left=right=NULL;
  }

  void add(int tl, int tr, AriPro tv) {
    if (l==tl && r==tr) {
      val = val+tv;
      sum = (sum+tv.sum(1, l-r+1))%MODS;
    } else {
      int mid=(l+r)/2;
      if (tl<=mid && tr>=l) {
	if (!left) {
	  left=new SegmentTree(l, mid);
	}
	left->add(max(tl, l), min(tr, mid), tv);
      }
      if (tl<=r && tr>mid) {
	if (!right) {
	  right=new SegmentTree(mid+1, r);
	}
	right->add(max(tl, mid+1), min(tr, r), AriPro(tv.kth(mid-l+2), tv.d));
      }
      sum = val.sum(1, l-r+1);
      if (left) {
	sum = (sum+left->sum)%MODS;
      }
      if (right) {
	sum = (sum+right->sum)%MODS;
      }
    }
  }

  long long get(int tl, int tr) {
    if (l==tl && r==tr) {
      return sum;
    } else {
      int mid=(l+r)/2;
      long long ret=val.sum(tl-l+1, tr-l+1)%MODS;
      if (tl<=mid && tr>=l && left) {
	ret = (ret+left->get(max(tl, l), min(tr, mid)))%MODS;
      }
      if (tl<=r && tr>mid && right) {
	ret = (ret+right->get(max(tl, mid+1), min(tr, r)))%MODS;
      }
      return ret;
    }
  }
};

int main() {
#ifdef DEBUG
  freopen("5232.in", "r", stdin);
  freopen("5232.out", "w", stdout);
#endif

  SegmentTree *below=new SegmentTree(0, MAXR), *above=new SegmentTree(0, MAXR);
  static int s[MAXN+1], l[MAXN+1], r[MAXN+1];
  static long long f[MAXN];
  
  int n;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    scanf("%d %d %d", s+i, l+i, r+i);
  }

  for (int i=1; i<=n; i++) {

  }

  fcloseall();
  return 0;
}
